/********************************************************************************
 * Copyright (c)2016-2020, ShenZhen WanJiaAn Technology CO.,LTD.
 * All Rights Reserved.
 *
 * File Name     : Video.h
 * Author        : joki.zhu
 * Date          : 2019-10-19
 *
 * Record        :
 * 1.Date        : 2019-10-19
 *   Author      : joki.zhu
 *   Modification: Created file
 ********************************************************************************/

#ifndef __VIDEO_H__
#define __VIDEO_H__

#include <pthread.h>
#include "MediaPack.h"

#ifdef __cplusplus
#if __cplusplus
extern "C"{
#endif
#endif /* __cplusplus */


/****************************************************************************************/
#define VIDEO_VENC_CHN_MAX_NUM      (3)
#define VIDEO_REG_MAX_NUM           (3)


/****************************************************************************************/
typedef enum {
    VIDEO_CHN_MAIN = 0,
    VIDEO_CHN_2END = 1,
    VIDEO_CHN_3TRD = 2,
    VIDEO_CHN_4RTH = 3,
    VIDEO_CHN_JPEG,
}VIDEO_CHN_E;

typedef struct {
    unsigned int width;
    unsigned int height;
    unsigned int bitrate;
    unsigned int framerate;
    unsigned int nGop;
    MEDIA_ENC_TYPE_E enVencType;
    MEDIA_VENC_RC_MODE_E enRcMode;
}VIDEO_STREAM_ATTR_S;

typedef enum {
    VIDEO_NIGHT_OFF = 0,
    VIDEO_NIGHT_ON,
    VIDEO_NIGHT_AUTO,
    VIDEO_NIGHT_MODE_NONE,
}VIDEO_NIGHT_MODE_E;

typedef struct {
    char bHorReverse;
    char bVerReverse;
    char reserved[2];
}VIDEO_FLIP_ATTR_S;

typedef int (*VideoVencDataCallback)(int chn, void *data);

typedef struct {
    int (*init)(void);
    int (*deinit)(void);

    int (*video_venc_start)(int chn, VideoVencDataCallback pfnVencDataCb);
    int (*video_venc_stop)(int chn, VideoVencDataCallback pfnVencDataCb);

    int (*video_copy_data)(int chn, void *data, MEDIA_PACK_VIDEO *pstPackVideo, int maxSize);
    
    int (*set_resolution)(VIDEO_CHN_E chn, VIDEO_STREAM_ATTR_S stStreamAttr);
    int (*set_resolution_without_config)(VIDEO_CHN_E chn, VIDEO_STREAM_ATTR_S stStreamAttr);
    int (*get_resolution)(VIDEO_CHN_E chn, VIDEO_STREAM_ATTR_S *pstStreamAttr);
    
    int (*request_idr_frame)(VIDEO_CHN_E chn);

    int (*set_flip)(VIDEO_FLIP_ATTR_S stFlipAttr);
    int (*get_flip)(VIDEO_FLIP_ATTR_S *pstFlipAttr);

    int (*set_daynight_mode)(VIDEO_CHN_E chn, VIDEO_NIGHT_MODE_E enNightMode);
    int (*get_daynight_mode)(VIDEO_CHN_E chn, VIDEO_NIGHT_MODE_E *pNightMode);

    int (*get_snap_pic)(unsigned char **pData, int *pSize);
}VIDEO_OPS_FUNC_S;

typedef int (*VideoRecvCallback)(int chn, MEDIA_PACK_VIDEO stPackVideo);

typedef struct {
    pthread_mutex_t mutexLock;
    VideoRecvCallback pfnRegVideoCbArry[VIDEO_REG_MAX_NUM];
}VIDEO_REG_ATTR_S;

int VideoInit(void);
int VideoDeinit(void);
VIDEO_OPS_FUNC_S *VideoGetOpsHandle(void);
int VideoRegisterRecvData(int chn, VideoRecvCallback pfnRcvVideoCb);
int VideoUnRegisterRecvData(int chn, VideoRecvCallback pfnRcvVideoCb);

#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif /* __cplusplus */


#endif /* __VIDEO_H__ */
